package basicSort.quickSort;

import java.util.Arrays;
import java.util.Collection;

public class Main {
    public static void main(String[] args) {
        int count = 500000;

        int[] arr = new int[count];

        //为数组随机赋值
        for ( int i = 0 ; i < count ; i++){
            arr[i] =(int) (Math.random() * 100);
        }

        //形成有序数组
        /*for ( int i = 0 ; i < count ; i++){
            arr[i] =i;
        }*/



        int[] arr2 = new int[count];
        int[] arr3 = new int[count];
        int[] arr4 = new int[count];

        System.arraycopy( arr , 0 , arr2 , 0 , count);
        System.arraycopy( arr , 0 , arr3 , 0 , count);
        System.arraycopy( arr , 0 , arr4 , 0 , count);

        System.out.println();
        System.out.println();

        //int[] arr = new int[]{3,8,6,2,7,9,1,4,5};

        long start = System.currentTimeMillis();
        //QuickSort.qsort(arr);
        long end = System.currentTimeMillis();
        System.out.println("普通快排花费时间 :" + (end-start));
        /*for( int i = 0 ; i < arr.length ; i++){
            System.out.print(arr[i]+" ");
        }*/

        System.out.println();

        start = System.currentTimeMillis();
        RandomQuickSort.randomQsort(arr2);
        end = System.currentTimeMillis();
        System.out.println("随机快排花费时间 :" + (end-start));
        /*for( int i = 0 ; i < arr2.length ; i++){
            System.out.print(arr2[i] + " ");
        }*/


        start = System.currentTimeMillis();
        Arrays.sort(arr3);
        end = System.currentTimeMillis();
        System.out.println("系统排序花费时间 :" + (end-start));

        start = System.currentTimeMillis();
        ThreeQuickSort.threeQuicksort(arr4);
        end = System.currentTimeMillis();
        System.out.println("三路快排排序花费时间 :" + (end-start));
    }
}
